package Q1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            List<Integer> list1 = new ArrayList<>();
            for (int i = 0; i <= n; i++) {
                list1.add(i);
            }

            while (list1.size() != 1) {
                List<Integer> list2 = new ArrayList<>();
                int count = 1;
                for (int num : list1) {
                    if (count % 2 == 0) {
                        list2.add(num);
                    }
                    count++;
                }
                list1 = new ArrayList<>(list2);
            }

            System.out.println(list1.get(0));
        }
    }
}
